<h1>Reporte de Efectivo Desglosado</h1>
<table > 
    <?php
    include_once '../../models/Factura.php';
    include_once '../../models/Nota.php';
    include_once '../../models/Deposito.php';
    
    $strFactura = "";
    
    $totalFacts = new Factura(null, null, null, null);
    $totalNots = new Nota(null, null, null, null, null);
    $totalDeps = new Deposito(null, null, null, null);
    
    //Empezamos desde el Enero del 2013
    $mes = 1;
    $anio = 2013;
    
    //Obtenemos las facturas, depositos y notas para el reporte
    $facturas = $totalFacts->getFacturasReporte($mes, $anio);
    $notas = $totalNots->getNotasReporte($mes, $anio);
    $totalDeps = $totalDeps->obtenerTotalDepositos();
    
    //Ponemos la cabecera de la tabla
    $strFactura .= "<tr>
                    <th bgcolor='#000000'></th>
                    <th bgcolor='#000000'></th>
                    <th bgcolor='#000000'></th>
                    <th bgcolor='#000000'></th>
                    <th bgcolor='#000000'>Total Depositos</th>
                    <th bgcolor='#000000'>$totalDeps</th>
                </tr>
                <tr>
                    <th bgcolor='#243B0B'>&nbsp;&nbsp; No. Factura &nbsp;&nbsp;</th>
                    <th bgcolor='#243B0B'>&nbsp;&nbsp;&nbsp;&nbsp; Fecha &nbsp;&nbsp;&nbsp;&nbsp;</th>
                    <th bgcolor='#243B0B'>&nbsp;&nbsp;&nbsp;&nbsp; Monto &nbsp;&nbsp;&nbsp;&nbsp;</th>
                    <th bgcolor='#243B0B'>&nbsp;&nbsp;&nbsp;&nbsp; Total Pagado &nbsp;&nbsp;&nbsp;&nbsp;</th>
                    <th bgcolor='#243B0B'>&nbsp;&nbsp;&nbsp;&nbsp; Adeudo &nbsp;&nbsp;&nbsp;&nbsp;</th>
                    <th bgcolor='#243B0B'>&nbsp;&nbsp;&nbsp;&nbsp; Restante Depositos &nbsp;&nbsp;&nbsp;&nbsp;</th>
                </tr>";
        
    while ($tempFact = mysql_fetch_array($facturas)) {
        
        //Obtenemos el total pagado
        $totalPagado = ($totalDeps > ($tempFact['monto'] * 1.16) ? ($tempFact['monto'] * 1.16) : $totalDeps );
        
        $strFactura .= "<tr>
                        <td>&nbsp;&nbsp; $tempFact[numfactura] &nbsp;&nbsp;</td>
                        <td>&nbsp;&nbsp;&nbsp;&nbsp; $tempFact[fechaemision] &nbsp;&nbsp;&nbsp;&nbsp;</td>
                        <td>&nbsp;&nbsp;&nbsp;&nbsp; $". ($tempFact['monto'] * 1.16) ." &nbsp;&nbsp;&nbsp;&nbsp;</td>
                        <td>&nbsp;&nbsp;&nbsp;&nbsp; $totalPagado &nbsp;&nbsp;&nbsp;&nbsp;</td>
                        <td>&nbsp;&nbsp;&nbsp;&nbsp; ". (($tempFact['monto'] * 1.16) - $totalPagado)  ." &nbsp;&nbsp;&nbsp;&nbsp;</td>
                        <td>&nbsp;&nbsp;&nbsp;&nbsp; ". (($totalDeps) - $totalPagado)  ." &nbsp;&nbsp;&nbsp;&nbsp;</td>
                    </tr>";
        
        $totalDeps = $totalDeps - ($totalPagado);
    }
    
    while ($tempNota = mysql_fetch_array($notas)) {
        
    }
    
    echo $strFactura;
    ?>  
</table>